﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DTO;
using DAO;

namespace Presentation
{
    public partial class UserControlToabacsi : UserControl
    {
        public UserControlToabacsi()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Visible = false;
        }

        private void btnTracuu_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime tngay = DateTime.Parse(dtpTungay.Text);
                DateTime dngay = DateTime.Parse(dtpDenngay.Text);
                BacSiKeToaDao bsktDao = new BacSiKeToaDao();
                BacSiKeToaDto[] bsktDto = bsktDao.SelectBacsiketoa(tngay, dngay);

                drvToabacsi.AutoGenerateColumns = false;
                drvToabacsi.DataSource = bsktDto;
            }
            catch (Exception )
            {

                MessageBox.Show("Không có dữ liệu!");
            }
        }

        private void drvToabacsi_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            DataGridView grv = (DataGridView)sender;
            Utils.MakeSothutuColumn(grv, "itemStt");
        }

        private void btnLuuBaoCao_Click(object sender, EventArgs e)
        {
            Utils.ExportToExcel(drvToabacsi);
        }
    }
}
